//
// Created by ziya on 2021/10/17.
//

#ifndef UNTITLED_JAVATHREAD_H
#define UNTITLED_JAVATHREAD_H
#include "../../include/common.h"
using namespace std;

class ParkEvent ;

enum ThreadState {
    ALLOCATED,                    // Memory has been allocated but not initialized
    INITIALIZED,                  // The thread has been initialized but yet started
    RUNNABLE,                     // Has been started and is runnable, but not necessarily running
    MONITOR_WAIT,                 // Waiting on a contended monitor lock
    CONDVAR_WAIT,                 // Waiting on a condition variable
    OBJECT_WAIT,                  // Waiting on an Object.wait() call
    BREAKPOINTED,                 // Suspended at breakpoint
    SLEEPING,                     // Thread.sleep()
    ZOMBIE                        // All done, but not reclaimed yet
};

class JavaThread {
public:
    string _name;

    pthread_t tid[1];

    pthread_attr_t attr[1];

    pthread_mutex_t  lock[1];

    pthread_cond_t condt[1];

    ThreadState threadState;

    static  ParkEvent* parkEvent;

public:
    JavaThread(string name);

    JavaThread(int idx);

    void run ();

};


#endif //UNTITLED_JAVATHREAD_H
